//------------------------------------------------------------------------------
//	file mm_err.c
//	brief
//		Converts MM errors to strings (implementation file)
//
//	$Id: mm_err.c 3 2014-04-19 07:10:51Z ac.verbeck@gmail.com $
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//	Copyright and Disclaimer Notice
//
//	The MIT License (MIT)
//	
//	Copyright (c) 2014 A.C. Verbeck
//	
//	Permission is hereby granted, free of charge, to any person obtaining a copy
//	of this software and associated documentation files (the "Software"), to deal
//	in the Software without restriction, including without limitation the rights
//	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//	copies of the Software, and to permit persons to whom the Software is
//	furnished to do so, subject to the following conditions:
//	
//	The above copyright notice and this permission notice shall be included in
//	all copies or substantial portions of the Software.
//	
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//	THE SOFTWARE.
//
//------------------------------------------------------------------------------

#include <stdint.h>																//	Standard int types
#include <stdbool.h>															//	Bool

#include <windows.h>
#include <mmsystem.h>

#include "mm_err.h"

static MM_ERROR_STR mm_err_str[] = {
	{	MMSYSERR_NOERROR,		"No error"				},
	{	MMSYSERR_ERROR,			"Unknown error"			},
	{	MMSYSERR_BADDEVICEID,	"Bad device"			},
	{	MMSYSERR_NOTENABLED,	"Not enabled"			},
	{	MMSYSERR_ALLOCATED,		"Already allocated"		},
	{	MMSYSERR_INVALHANDLE,	"Invalid handle"		},
	{	MMSYSERR_NODRIVER,		"No driver"				},
	{	MMSYSERR_NOMEM,			"No memory available"	},
	{	MMSYSERR_NOTSUPPORTED,	"Not supported"			},
	{	MMSYSERR_BADERRNUM,		"Bad error number"		},
	{	MMSYSERR_INVALFLAG,		"Invalid flag"			},
	{	MMSYSERR_INVALPARAM,	"Invalid parameter"		},
	{	MMSYSERR_HANDLEBUSY,	"Handle is busy"		},
	{	MMSYSERR_INVALIDALIAS,	"Invalid alias"			},
	{	MMSYSERR_BADDB,			"Bad DB"				},
	{	MMSYSERR_KEYNOTFOUND,	"Key not found"			},
	{	MMSYSERR_READERROR,		"Read error"			},
	{	MMSYSERR_WRITEERROR,	"Write error"			},
	{	MMSYSERR_DELETEERROR,	"Delete error"			},
	{	MMSYSERR_VALNOTFOUND,	"Value not found"		},
	{	MMSYSERR_NODRIVERCB,	"No driver CB"			},
	{	WAVERR_BADFORMAT,		"Bad format"			},
	{	WAVERR_STILLPLAYING,	"Still playing"			},
	{	WAVERR_UNPREPARED,		"Buffer unprepared"		}
};
#define	MM_ERR_CT	(sizeof(mm_err_str)/sizeof(MM_ERROR_STR))

char*	getMMErrString(uint16_t id)
{
	uint16_t	idx=0;
	char*		rStr = "Undefined";

	for (idx=0; idx<MM_ERR_CT; idx++) {
		if (mm_err_str[idx].id == id) {
			rStr = mm_err_str[idx].str;
			break;
		}
	}
	return rStr;
}


//
//	End: mm_err.c
//
